const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser')
const fs = require('fs')
const config = JSON.parse(fs.readFileSync('./config/config.json', 'utf-8'))
const app = express()

// 跨域
app.use(cors())

// 解析post中间件
app.use(bodyParser.urlencoded({ extended: false }))
app.use(express.static(__dirname + '/public'))
const Router = require('./router/index')
app.use('/api', Router)

// 启动监听
app.listen(config.port, () => {
    console.log(`success!! Server running at http://localhost:${config.port}/`)
})